package org.topofalps.vocabularyTutor;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.google.appengine.api.users.User;

/**
 * The class for word, the basic storage unit. Word can be persisted as a JDO.
 * Java Data Objects should all have getter and setter methods for every field.
 * 
 * 
 * @author Zijiang Yang
 * @version 0.1
 */

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Word {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;

	@Persistent
	private User author;

	@Persistent
	private String word;
	
	@Persistent
	private List<String> definitions;

	@Persistent
	private Date dateCreated;

	/**
	 * constructor with definitions provided
	 */
	public Word(User author, List<String> definitions, Date date) {
		this.author = author;
		this.definitions = definitions;
		this.dateCreated = date;
	}
	
	/**
	 * constructor with definitions left to be filled in later
	 */
	public Word(User author, Date date) {
		this.author = author;
		this.definitions = new ArrayList<String>();
		this.dateCreated = date;
	}
	
	/**
	 * getter for definitions
	 * @return definitions
	 */
	public List<String> getDefinitions() {
		return definitions;
	}

	/**
	 * setter for definitions
	 * @param definitions
	 */
	public void setDefinitions(List<String> definitions) {
		this.definitions = definitions;
	}

	
	/**
	 * getter for dateCreated
	 * @return dateCreated
	 */
	public Date getDateCreated() {
		return dateCreated;
	}

	/**
	 * setter for dateCreated
	 * @param dateCreated
	 */
	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	/**
	 * getter for id
	 * @return id
	 */
	public Long getId() {
		return id;
	}
	
	/**
	 * setter for id
	 * @param id
	 */
	public void setId(Long id) {
		this.id = id;
	}
	
	/**
	 * getter for the string form of word
	 * @return word
	 */
	public String getWord() {
		return word;
	}

	/**
	 * setter for the string form of word
	 * @param word
	 */
	public void setWord(String word) {
		this.word = word;
	}

	
	/**
	 * getter for the user who queried this entry
	 * 
	 * @return author
	 */
	public User getAuthor() {
		return author;
	}

	/**
	 * setter for the user who queried this entry
	 * 
	 * @return author
	 */
	public void setAuthor(User author) {
		this.author = author;
	}
	
	/**
	 * add extra definitions
	 * @param definition
	 */
	public void addDefinition(String definition) {
		this.definitions.add(definition);
	}
}
